<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>确认支付</title>
    <link rel="stylesheet" type="text/css" href="css/base.css"/>
    <link rel="stylesheet" type="text/css" href="css/zhifu.css"/>
    <link rel="stylesheet" type="text/css" href="css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="css/loaders.min.css"/>
    <link rel="stylesheet" type="text/css" href="css/loading.css"/>
	<link rel="stylesheet" href="/js/plugins/dialog/dialog.css"/>

    <script src="js/rem.js"></script>
	<script src="/js/jquery/jquery.min.js"></script>
	<script src="/js/bootstrap/js/bootstrap.min.js"></script>
	<script src="/js/plugins/jrender/jrender.js"></script>
	<script src="/js/plugins/dialog/dialog.min.js"></script>
	<script src="/js/common.js"></script>

	<script type="text/javascript">
		$(function(){

            //获取session积分,给对应id的块赋值
            var total = JSON.parse(sessionStorage.getItem("totalString"));
            $("#totalIntegral").html(total);

		    //商品id数组
            var productIds = JSON.parse(sessionStorage.getItem("productIdsStr"));
            //订单id数组
            var indentIds = JSON.parse(sessionStorage.getItem("indentIdsStr"));
            console.log(indentIds);
            var user = JSON.parse(sessionStorage.getItem("user"));
            $(".loading").addClass("loader-chanage")
            $(".loading").fadeOut(300);
		//计算内容上下padding
			reContPadding({main:"#main",header:"#header",footer:"#footer"});
			function reContPadding(o){
				var main = o.main || "#main",
					header = o.header || null,
					footer = o.footer || null;
				var cont_pt = $(header).outerHeight(true),
					cont_pb = $(footer).outerHeight(true);
				$(main).css({paddingTop:cont_pt,paddingBottom:cont_pb});
			}



			//确认支付
			$("#paymentBtn").click(function () {
                //indentIds = JSON.parse(sessionStorage.getItem("indentIdsStr"));
                //这是订单的ids
                $.each(indentIds, function (index, ele) {
                    console.log(ele);
                    //ele就是每个订单id
                    //发送ajax请求修改用户的订单,并扣除用户的相应积分
                    $.ajax({
                        url: "/order/"+ele+"/indent?state="+1+"&userId="+user.id,
                        type: "PUT",
                        success: function () {
                            window.location.href = "/shop/indent.html";
                        }
                    })
                });
            });
		});
	</script>
</head>
<!--loading页开始-->
<div class="loading">
	<div class="loader">
        <div class="loader-inner pacman">
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
        </div>
	</div>
</div>
<!--loading页结束-->
	<body>
		<header class="mui-bar mui-bar-nav report-header box-s" id="header">
			<a href="javascript:history.go(-1)"><i class="iconfont icon-fanhui fl"></i></a>
			<p>确认支付</p>
	    </header>
	    <div id="main" class="mui-clearfix contaniner sorder">	    	
	    	<div class="warning clearfloat box-s">
    			提示：请在24小时内完成在线支付，逾期将视为订单无效
    		</div>
    		<div class="odernum clearfloat travels">
    			<ul>
    				<li>应付积分：<span id="totalIntegral"></span></li>
    			</ul>
    		</div>

	    	<a class="address-add fl payment" role="button" id="paymentBtn">
	     		确认支付
	     	</a>
	    </div>
	    
	</body>
</html>
